#pragma once
#include "hge.h"  
#include "hgeSprite.h"  
#include<iostream>
using namespace std;
#include"Map.h"
class Abnormal_state{
public:
	int tortoise_round;
	int remote_dice;
	int dice_num;
	int hospital_round;
	int black_house_round;
	bool	clockwise;
	Abnormal_state(){
		tortoise_round=0;
		remote_dice=0;
		dice_num=1;
		hospital_round=0;
		black_house_round=0;
		clockwise=true;
	}

};
class PropsOfRole{
public:
	int Car;
	int CtrlDice;

	int CtrlFlyBomb;
	int CtrlBack;
	int CtrlBomb;
	int CtrlDoor;

	PropsOfRole(){
		Car=1;
		CtrlDice=10;
		CtrlFlyBomb=2;
		CtrlBack=2;
		CtrlBomb=2;
		CtrlDoor=2;
	}
};
class CardsOfRole{
public:
	int CtrlBack;
	int CtrlOwnPlace;
	int CtrlStealHouse;
	int CtrlChange;
	int CtrlStealBike;
	int CtrlBuild;

	CardsOfRole(){
		CtrlBack=2;
		CtrlOwnPlace=2;
		CtrlStealHouse=2;
		CtrlChange=2;
		CtrlStealBike=2;
		CtrlBuild=2;
	}
};
class Role:public cell{
	bool		show;
public:
	int chosen_order;
	int characterIndex;
	int			money;
	int			point;
	int			PosNum;
	bool		has_car;
	Abnormal_state abState;
	PropsOfRole		role_props;
	CardsOfRole   role_cards;
	hgeSprite	*m_pwalk;
	HTEXTURE	 m_texwalk;
	hgeSprite	*m_pcar;
	HTEXTURE	 m_texcar;
	Role(HGE *pHge,int x,int y,string name,int Index,int order)
		:cell(pHge,x,y,name){
		characterIndex=Index;
		chosen_order=order;
		show=true;
		has_car=false;
		PosNum=0;
		point=0;
		money=100000;
		string str="role";str+=('0'+Index);str+="withcar.png";
		m_texwalk	=m_phge->Texture_Load(name.c_str());
		m_texcar	=m_phge->Texture_Load(str.c_str());
		m_pwalk=NULL;
		m_pcar=NULL;
	}
	virtual void update(int nowX,int nowY){
		cell::update(nowX,nowY);
		m_texcell=(has_car?m_texcar:m_texwalk);
		m_pcell=(has_car?m_pcar:m_pwalk);
		m_pcell->SetZ(1-mapY/10000.0);
	}
	virtual void createSpr(int x,int y){
		if(m_pwalk!=NULL)
			delete m_pwalk;
		m_pwalk=new hgeSprite(m_texwalk,x*128,y*128,128,128);
		m_pwalk->SetZ(1-mapY/10000.0);
		if(m_pcar!=NULL)
			delete m_pcar;
		m_pcar=new hgeSprite(m_texcar,x*128,y*128,128,128);
		m_pcar->SetZ(1-mapY/10000.0);

		m_texcell=(has_car?m_texcar:m_texwalk);
		m_pcell=(has_car?m_pcar:m_pwalk);
		/*if(m_pcell!=NULL)
			delete m_pcell;
		m_pcell=new hgeSprite(m_texcell,x*128,y*128,128,128);
		m_pcell->SetZ(1-mapY/10000.0);*/
	}
	virtual void Render(){
		if(m_pcell!=NULL&&show)
			m_pcell->Render(screenX-64,screenY-96);
	}
	void visible(bool v){
		show=v;
	}
	void setPos(int x,int y){
		virX=x;
		virY=y;
	}
};